﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Collections;

namespace BLL
{
    public class TinhTPBLL
    {
        LandEntities data = new LandEntities();
        public TinhTPBLL()
        { }

        public List<TINH_TP> DanhSachTinhThanhPho()
        {
            var tinh_tp = from t in data.TINH_TP
                          select t;
            return tinh_tp.ToList<TINH_TP>();
        }

        public void ThemTinhThanhPho(string maT, string tenT)
        {
            TINH_TP tinh = new TINH_TP();
            tinh.MATINHTP = maT;
            tinh.TENTINHTP = tenT;
            data.TINH_TP.AddObject(tinh);
            data.SaveChanges();
        }

        public void XoaTinhThanhPhot(string maT)
        {
            TINH_TP tinh_tp = data.TINH_TP.Single(t => t.MATINHTP == maT);
            data.DeleteObject(tinh_tp);
            data.SaveChanges();
        }

        public void SuaTinhThanhPho(string maT, string tenT)
        {
            TINH_TP tinh_tp = data.TINH_TP.Single(t => t.MATINHTP == maT);
            tinh_tp.TENTINHTP = tenT;
            data.SaveChanges();
        }
    }
}
